const User = require('../../models/user')

module.exports = (req, res) => {
  const formData = {}
  // console.log(req.body);
  formData.username = req.body.username
  formData.password = req.body.password
  formData.email = req.body.email
  formData.role = req.body.role
  formData.created_time = new Date
  formData.last_modified_time = new Date
  // console.log(formData);
  new User(formData).save((err, userDoc) => {
    if (err) {
      return res.status(500).json({
        err_code: 500,
        message: err.message
      })
    }
    res.status(200).json({
      err_code: 0,
      message: 'insert success'
    })
  })
}